var a = getApp();

Page({
    data: {
        active: "record",
        nickname: "",
        avatar_image: "",
        agent_level: "",
        grand_amount: "",
        list: [],
        page: 1,
        last_page: 1
    },
    onLoad: function() {
        this.getData();
    },
    onChange: function(a) {
        this.setData({
            active: a.detail.name
        }), "record" == this.data.active ? this.getData(1) : this.getLevelData(1);
    },
    getLevelData: function() {
        var t = this, e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 1;
        a._postNetWork({
            url: a.getNetAddresss("plugin.subscription.frontend.modules.tier.controllers.records.index"),
            data: {
                page: e
            },
            success: function(n) {
                if (n.data.result) {
                    var s = n.data.data;
                    (e = 1) ? t.setData({
                        list: s.page_list.data,
                        last_page: s.page_list.last_page,
                        nickname: s.nickname,
                        avatar_image: s.avatar_image,
                        agent_level: s.agent_level,
                        grand_amount: s.grand_amount
                    }) : t.setData({
                        list: t.data.list.concat(s.page_list.data),
                        page: s.page_list.current_page
                    });
                } else a.tips(n.data.msg);
            }
        });
    },
    getData: function() {
        var t = this, e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 1;
        a._postNetWork({
            url: a.getNetAddresss("plugin.subscription.frontend.modules.bonus.controllers.records.index"),
            data: {
                page: e
            },
            success: function(n) {
                if (n.data.result) {
                    var s = n.data.data;
                    (e = 1) ? t.setData({
                        list: s.page_list.data,
                        last_page: s.page_list.last_page,
                        nickname: s.nickname,
                        avatar_image: s.avatar_image,
                        agent_level: s.agent_level,
                        grand_amount: s.grand_amount
                    }) : t.setData({
                        list: t.data.list.concat(s.page_list.data),
                        page: s.page_list.current_page
                    });
                } else a.tips(n.data.msg);
            }
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        if (this.data.page >= this.data.last_page) return !1;
        "record" == this.data.active ? this.getData(this.data.page + 1) : this.getLevelData(this.data.page + 1);
    },
    onShareAppMessage: function() {}
});